import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'controllers/count_controller.dart';
class GetXDialogPage extends StatelessWidget {
  const GetXDialogPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('GetXDialog'),
        ),
        body: HomePage()
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final GetXCountController _countController = Get.find();
  @override
  Widget build(BuildContext context) {
    return  Center(
      child: Column(
        children: [
          Obx(() => Text('点击了${_countController.counter.value}次')),
          ///defaultDialog
          ElevatedButton(
            onPressed: (){
              Get.defaultDialog(
                radius: 5,
                title: 'GetXDialog',
                middleText: '这是一个GetXDialog',
                confirm: ElevatedButton(onPressed: (){
                  print("点击确定");
                  Get.back();
                }, child: Text('确定')),
                cancel: ElevatedButton(onPressed: (){
                  print("点击取消");
                  Get.back();
                }, child: Text('取消')),
              );
            },
            child: Text('Show Dialog'),
          ),
      ///snackbar toast提示
          ElevatedButton(
            onPressed: (){
              Get.snackbar("提示！", "这是一个GetXSnackbar", snackPosition: SnackPosition.BOTTOM);
            },
            child: Text('toast提示'),
          ),
          ///

        ],
      ),
    );
  }
}
